package com.stan.core.mapper;

import com.stan.core.mapper.factory.MapperFactory;
import com.stan.core.vo.AdStreamBlackList;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;
import java.util.List;

@Mapper
public interface AdStreamBlackListMapper {
    @Select("select user_id as userId from t_black_user_list")
    List<AdStreamBlackList> findAllBlackList();

    @Insert("<script>" +
            "insert into t_black_user_list (user_id) values " +
            "<foreach collection='adBlackListDTOs' item='item' separator=','> " +
            "(#{item.userId})" +
            "</foreach>" +
            "</script>")
    void insertBatch(@Param("adBlackListDTOs") List<AdStreamBlackList> adStreamBlackLists);


    

    /**
     * 测试
     * @param args
     */
    public static void main(String[] args) {
        AdStreamBlackList adStreamBlackList = new AdStreamBlackList();
        adStreamBlackList.setUserId("10");
        MapperFactory mapperFactory = MapperFactory.getMapperFactory();
        AdStreamBlackListMapper adStreamBlackListMapper = mapperFactory
                .getMapper(AdStreamBlackListMapper.class);
        List<AdStreamBlackList> adStreamBlackListList = new ArrayList<>();
        adStreamBlackListList.add(adStreamBlackList);
        adStreamBlackListMapper.insertBatch(adStreamBlackListList);
    }

}
